const glob = require("glob");
const path = require("path");
const { EntitySchema } = require("typeorm"); 
const types = require("./types.js");

const entryFiles = glob.sync(path.join(__dirname,'..','..','**/model/**/*.js'));
const modules = {};

entryFiles.forEach(file=> {
    const entries = require(file)(types);
        Object.keys(entries).forEach(entryKey=> {
            modules[entryKey] = new EntitySchema({
                "name": entryKey,
                "columns": entries[entryKey]
            })
    })
})

module.exports = modules;